﻿<Window x:Class="LogicCircuit.DialogText"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:lc="clr-namespace:LogicCircuit"
	xmlns:properties="clr-namespace:LogicCircuit.Properties"
	WindowStartupLocation="CenterOwner"
	Title="{x:Static properties:Resources.TextNotation}"
	MinWidth="580" MinHeight="300"
	Style="{StaticResource DialogWindow}"
	FocusManager.FocusedElement="{Binding ElementName=editor}"
>
	<lc:AutoGrid ColumnWidths="*">
		<ToolBarTray>
			<ToolBarTray.Resources>
				<lc:RemoveAcceleratorConverter x:Key="RemoveAcceleratorConverter"/>

				<Style TargetType="ToggleButton" x:Key="toolToggleButton">
					<Setter Property="CommandTarget" Value="{Binding ElementName=editor}"/>
					<Setter Property="VerticalAlignment" Value="Stretch"/>
					<Setter Property="Width" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=ActualHeight}"/>
					<Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Command.Text, Converter={StaticResource RemoveAcceleratorConverter}}"/>
					<Style.Triggers>
						<Trigger Property="IsEnabled" Value="False">
							<Setter Property="Opacity" Value="0.5"/>
						</Trigger>
					</Style.Triggers>
				</Style>
			</ToolBarTray.Resources>
			<!-- Edit Toolbar -->
			<ToolBar Band="{Binding Path=EditToolBarBand.Value, Mode=TwoWay}" BandIndex="{Binding Path=EditToolBarBandIndex.Value, Mode=TwoWay}">
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="ApplicationCommands.Cut">
					<Image Source="..\Properties\EditCut.png" Height="24"/>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="ApplicationCommands.Copy">
					<Image Source="..\Properties\EditCopy.png"/>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="ApplicationCommands.Paste">
					<Image Source="..\Properties\EditPaste.png"/>
				</ToggleButton>

				<Separator/>

				<ToggleButton Style="{StaticResource toolToggleButton}" Command="ApplicationCommands.Undo">
					<Image Source="..\Properties\EditUndo.png"/>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="ApplicationCommands.Redo">
					<Image Source="..\Properties\EditRedo.png"/>
				</ToggleButton>
			</ToolBar>
			<!-- Font Toolbar -->
			<ToolBar Band="{Binding Path=FontToolBarBand.Value, Mode=TwoWay}" BandIndex="{Binding Path=FontToolBarBandIndex.Value, Mode=TwoWay}">
				<ComboBox Width="150" ItemsSource="{Binding Path=FontFamilies}" SelectedItem="{Binding Path=CurrentFontFamily}" ToolTip="{x:Static properties:Resources.ToolTipFontFamily}">
					<ComboBox.ItemTemplate>
						<DataTemplate>
							<TextBlock Text="{Binding Path=Source}" FontFamily="{Binding}" FontSize="16" ToolTip="{Binding}"/>
						</DataTemplate>
					</ComboBox.ItemTemplate>
				</ComboBox>

				<ComboBox Width="50" ItemsSource="{Binding Path=FontSizes}" SelectedItem="{Binding Path=CurrentFontSize}" ToolTip="{x:Static properties:Resources.ToolTipFontSize}" VerticalAlignment="Stretch"/>

				<ToggleButton Name="boldButton" Style="{StaticResource toolToggleButton}" Command="EditingCommands.ToggleBold" IsChecked="{Binding Path=IsBoldFont, Mode=OneWay}">
					<TextBlock FontSize="18" FontWeight="Bold">B</TextBlock>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.ToggleItalic" IsChecked="{Binding Path=IsItalicFont, Mode=OneWay}">
					<TextBlock FontSize="18" FontWeight="Bold" FontStyle="Italic">I</TextBlock>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.ToggleUnderline" IsChecked="{Binding Path=IsUnderlineFont, Mode=OneWay}">
					<TextBlock FontSize="18" FontWeight="Bold" TextDecorations="Underline">U</TextBlock>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.IncreaseFontSize">
					<Image Source="..\Properties\CharacterGrowFont.png"></Image>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.DecreaseFontSize">
					<Image Source="..\Properties\CharacterShrinkFont.png"></Image>
				</ToggleButton>

				<lc:ColorPicker ColorPickerMode="Background" ToolTip="{x:Static properties:Resources.ToolTipBackgroundColor}"
					SelectedColor="{Binding Path=HighlightColor, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged, NotifyOnTargetUpdated=True}"
				/>
				<lc:ColorPicker ColorPickerMode="Foreground" ToolTip="{x:Static properties:Resources.ToolTipFontColor}"
					SelectedColor="{Binding Path=ForegroundColor, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged, NotifyOnTargetUpdated=True}"
				/>
			</ToolBar>
			<!-- Paragraph Toolbar -->
			<ToolBar Band="{Binding Path=ParaToolBarBand.Value, Mode=TwoWay}" BandIndex="{Binding Path=ParaToolBarBandIndex.Value, Mode=TwoWay}">
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.ToggleBullets" IsChecked="{Binding Path=IsBulleted, Mode=OneWay}">
					<Image Source="..\Properties\ListBullets.png"/>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.ToggleNumbering" IsChecked="{Binding Path=IsNumbered, Mode=OneWay}">
					<Image Source="..\Properties\ListNumbering.png"/>
				</ToggleButton>

				<Separator />

				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.AlignLeft" IsChecked="{Binding Path=IsLeftAlignment, Mode=OneWay}">
					<Image Source="..\Properties\ParagraphLeftJustify.png"/>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.AlignCenter" IsChecked="{Binding Path=IsCenterAlignment, Mode=OneWay}">
					<Image Source="..\Properties\ParagraphCenterJustify.png"/>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.AlignRight" IsChecked="{Binding Path=IsRightAlignment, Mode=OneWay}">
					<Image Source="..\Properties\ParagraphRightJustify.png"/>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.AlignJustify" IsChecked="{Binding Path=IsJustifyAlignment, Mode=OneWay}">
					<Image Source="..\Properties\ParagraphFullJustify.png"/>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.IncreaseIndentation" IsChecked="False">
					<Image Source="..\Properties\ParagraphIncreaseIndentation.png"></Image>
				</ToggleButton>
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="EditingCommands.DecreaseIndentation" IsChecked="False">
					<Image Source="..\Properties\ParagraphDecreaseIndentation.png"></Image>
				</ToggleButton>
			</ToolBar>
			<!-- Other Toolbar -->
			<ToolBar Band="{Binding Path=OtherToolBarBand.Value, Mode=TwoWay}" BandIndex="{Binding Path=OtherToolBarBandIndex.Value, Mode=TwoWay}">
				<ToggleButton Style="{StaticResource toolToggleButton}" Command="{Binding Path=HyperlinkCommand}">
					<Image Source="..\Properties\Hyperlink.png"/>
				</ToggleButton>

				<ToggleButton Style="{StaticResource toolToggleButton}" Command="{Binding Path=InsertImageCommand}">
					<Image Source="..\Properties\Image.png"/>
				</ToggleButton>
			</ToolBar>
		</ToolBarTray>

		<RichTextBox Name="editor" AcceptsReturn="True" AcceptsTab="True" SpellCheck.IsEnabled="True" TextChanged="editorTextChanged" SelectionChanged="editorSelectionChanged"
			VerticalScrollBarVisibility="Auto"
			HorizontalScrollBarVisibility="Auto"
		/>

		<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom">
			<Button Content="{x:Static properties:Resources.TitleOK}" IsDefault="True" Click="ButtonOkClick"/>
			<Button Content="{x:Static properties:Resources.TitleCancel}" IsCancel="True"/>
		</StackPanel>
	</lc:AutoGrid>
</Window>
